package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.common.VMSystem;
import com.lkd.config.TopicConfig;
import com.lkd.emq.Topic;
import com.lkd.entity.OrderEntity;
import com.lkd.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author Administrator
 */
@Component
@Topic(TopicConfig.ORDER_CHECK_TOPIC)
public class OrderCheckHandler implements MsgHandler {
    @Autowired
    private OrderService orderService;

    @Override
    public void process(String jsonMsg) throws IOException {
        OrderEntity order = orderService.getByOrderNo(jsonMsg);
        if (order.getPayStatus().equals(VMSystem.PAY_STATUS_NOPAY)) {
            //修改订单状态
            order.setPayStatus(VMSystem.ORDER_STATUS_INVALID);
            orderService.updateById(order);
        }
    }
}
